package com.szzg10.mina2.chapter2;

import java.util.Date;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

public class UdpServerHandler extends IoHandlerAdapter {

	@Override
	public void sessionCreated(IoSession session) throws Exception {
		System.out.println("Session created!!!");
	}
	
	@Override
	public void messageReceived(IoSession session, Object message)
			throws Exception {
		
		String str = message.toString();
		Long temp = Long.parseLong(str);
		System.out.println(temp / 1024 / 1024);
		
		Date date = new Date();
		str = date.toString();
		
		session.write(str);
	}
	
	@Override
	public void sessionClosed(IoSession session) throws Exception {
		System.out.println("Session closed!!!");
	}
	
}
